<template>
  <V-CommonHeaderLeft>
    <div class="purchasing-order">
      <Navigation :msg="navMsg"></Navigation>
      <div class="purchasing-table">
        <el-table ref="multipleTable"
                  :data="stock"
                  style="width: 100%;"
                  :height="tableHeight"
                  class="table-class">
          <el-table-column min-width='15%'
                           label="商品名称/商品编号">
            <template slot-scope="scope">
              <div class="name-id">
                <img src="../../../../static/images/100.jpg"
                     alt="">
                <div>
                  <span :title="scope.row.from.name">{{ scope.row.from.name }}</span>
                  <span title="A507">A507</span>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="orderId"
                           min-width='10%'
                           label="规格/规格编号">
            <template slot-scope="scope">
              <span title="黑色">黑色</span>
              <span :title="scope.row.orderId">{{ scope.row.orderId }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="from.name"
                           min-width='8%'
                           label="单位">
            <template slot-scope="scope">
              <span :title="scope.row.from.name">{{ scope.row.from.name }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="amountPaid"
                           min-width='8%'
                           label="可用库存">
            <template slot-scope="scope">
              <span :title="scope.row.amountPaid">{{ scope.row.amountPaid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="amountPaid"
                           min-width='8%'
                           label="订购数">
            <template slot-scope="scope">
              <span :title="scope.row.amountPaid">{{ scope.row.amountPaid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderStatus"
                           min-width='8%'
                           label="系统库存">
            <template slot-scope="scope">
              <span>{{ scope.row.orderStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderAmount"
                           min-width='8%'
                           label="采购中">
            <template slot-scope="scope">
              <span :title="scope.row.orderAmount">{{ scope.row.orderAmount }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="financialStatus"
                           min-width='11.67%'
                           class="purchase-num"
                           label="采购数">
            <template slot-scope="scope">
              <el-input placeholder="4"
                        v-model="scope.row.purchaseNum"
                        clearable>
              </el-input>
            </template>
          </el-table-column>
          <el-table-column min-width='11.67%'
                           label="供应商">
            <template slot-scope="scope">
              <el-select filterable
                         class="supplier"
                         v-model="scope.row.supplier"
                         placeholder="请选择供应商">
                <el-option v-for="item in scope.row.options"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="financialStatus"
                           min-width='11.67%'
                           class="price"
                           label="采购单价">
            <template slot-scope="scope">
              <el-input placeholder="请输入采购单价"
                        v-model="scope.row.price"
                        clearable>
              </el-input>
            </template>
          </el-table-column>
        </el-table>
        <Paging :msg="pageMsg.length"
                ref="fn"
                @pageNum="getPageNum"
                @pageId="getPageId"></Paging>
      </div>
    </div>
  </V-CommonHeaderLeft>
</template>
<script>
import VCommonHeaderLeft from '@/components/common/vCommonHeaderLeft/VCommonHeaderLeft'
import Navigation from '@/components/common/navigation/Navigation'
import Paging from '@/components/common/paging/Paging'
export default {
  data () {
    return {
      tableHeight: '',
      pageNum: 15, // 每页默认显示15条,
      pageId: 1, // 页面id
      judgeStatus: false, // 排序状态
      navMsg: [
        {
          name: '采购',
          path: '/purchasingOrder'
        },
        {
          name: '智能采购',
          path: ''
        }
      ],
      stock: [],
      pageMsg: [
        {
          id: 1,
          orderId: 'CK-20190412-0003',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: '',
          options: [{
            value: '1',
            label: 'XXL'
          }, {
            value: '2',
            label: 'adidas'
          }, {
            value: '3',
            label: 'nick'
          }],
          purchaseNum: '',
          supplier: '',
          price: ''
        },
        {
          id: 2,
          orderOrder: '智',
          orderId: 'CK-20190423-0043',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: '',
          options: [{
            value: '1',
            label: 'XXL'
          }, {
            value: '2',
            label: 'adidas'
          }, {
            value: '3',
            label: 'nick'
          }],
          purchaseNum: '',
          supplier: '',
          price: ''
        },
        {
          id: 3,
          orderId: 'CK-20100422-023',
          from: {
            type: '供应商',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '待发货',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: '',
          options: [{
            value: '1',
            label: 'XXL'
          }, {
            value: '2',
            label: 'adidas'
          }, {
            value: '3',
            label: 'nick'
          }],
          purchaseNum: '',
          supplier: '',
          price: ''
        },
        {
          id: 4,
          orderId: 'CK-20200422-0563',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-21',
          submitTime: '2019-04-23',
          eemarks: '',
          options: [{
            value: '1',
            label: 'XXL'
          }, {
            value: '2',
            label: 'adidas'
          }, {
            value: '3',
            label: 'nick'
          }],
          purchaseNum: '',
          supplier: '',
          price: ''
        }
      ]
    }
  },
  components: {
    Navigation,
    Paging,
    VCommonHeaderLeft
  },
  created () {
    this.stock = this.pageMsg
    this.getHight()
    window.addEventListener('resize', this.getHight)
  },
  destroyed () {
    window.removeEventListener('resize', this.getHight)
  },
  methods: {
    getHight () {
      this.tableHeight = window.innerHeight - 162 + 'px'
    },
    getPageId (id = 1) {
      this.pageId = id
      this.stock = this.$refs.fn.sliceArray(this.pageMsg, this.pageNum, id - 1)
    },
    getPageNum (num) {
      this.pageNum = num
      this.getPageId()
    }
  }
}
</script>
<style lang="scss" scoped>
.purchasing-order {
  width: 100%;
  margin-right: 10px;
  overflow: hidden;
  background-color: #ffffff;
  .purchasing-table {
    width: 100%;
    @mixin el-common($el-color, $el-height, $el-class) {
      color: $el-color;
      height: $el-height;
      line-height: $el-height;
      &:first-child {
        padding: 0;
      }
      #{$el-class} {
        width: 100%;
        line-height: 20px;
        display: -webkit-box;
        overflow: hidden;
        white-space: normal !important;
        text-overflow: ellipsis;
        word-wrap: break-word;
        word-break: break-all;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }
    /deep/ .el-table__body-wrapper {
      overflow-x: hidden;
      overflow-y: hidden;
      &:hover {
        overflow-y: overlay;
      }
      &::-webkit-scrollbar {
        width: 8px;
        height: 50%;
      }
      &::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background-color: rgba(0, 0, 0, 0.2);
      }
      &::-webkit-scrollbar-track {
        border-radius: 0;
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
    /deep/ .table-class {
      font-size: 12px;
      tr {
        td {
          padding: 4px 0 4px 24px;
          @include el-common(
            $el-color: #333,
            $el-height: 40px,
            $el-class: "span"
          );
          .name-id {
            width: 100%;
            display: flex;
            align-items: center;
            img {
              width: 46px;
              height: 46px;
              padding-right: 16px;
            }
          }
        }
        th {
          padding-left: 24px;
          @include el-common(
            $el-color: #666,
            $el-height: 50px,
            $el-class: ".cell"
          );
          font-weight: normal;
          background-color: #fcfcfc;
        }
        .el-table_1_column_8,
        .el-table_1_column_9,
        .el-table_1_column_10 {
          padding: 4px 0;
        }
      }
      .el-checkbox__input {
        display: inline-block;
        width: 14px;
        height: 14px;
      }
      .el-table_1_column_8,
      .el-table_1_column_9,
      .el-table_1_column_10 {
        padding: 4px 0;
        .cell {
          padding: 0;
          width: calc(100%);
          // border: 1px solid #000;
          .el-input--suffix {
            padding: 0;
            height: 100%;
            font-size: 12px;
            border-radius: 2px;
            .el-input__inner {
              padding: 0 12px;
            }
            .el-input__suffix-inner {
              padding: 0;
              text-align: right;
            }
          }
        }
      }
    }
  }
}
</style>
